<?php

namespace App\Http\Controllers\Common;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ZanController extends Controller
{
    public function make(Request $request){
        $model=hd_model();
        if($zan=$model->isZan(auth()->user())){
            $zan->delete();
        }else{
            $model->zan()->create(['user_id'=>auth()->id()]);
        }

        if($request->ajax()){
            return ['code'=>0,'zan_num'=>hd_model()->zan_num];
        }

            return back()->with('success','操作成功');

    }

}
